package com.liumo.domain.intface;

import java.io.Serializable;
import java.util.Random;

public abstract class BinaryOperation implements Serializable {
    protected Integer one;   // 第一个操作数
    protected Integer two;   // 第二个操作数
    protected Integer result; // 结果
    protected String aChar;   // 运算符，如 "+" 或 "-"
    protected String BinaryOperationStr; // 运算式的字符串表示
    protected String BinaryBaseStr;
    public BinaryOperation() {
    }

    // 构造函数

    // 生成格式化的运算式
    public BinaryOperation createBinaryOperation() {
        count();
        BinaryBaseStr = (String.format("%-2d %-3s %-2d = ", one, aChar, two));
        BinaryOperationStr = String.format("%-2d %-3s %-2d = %-2d \t\t", one, aChar, two, result);
        return this;
    }

    // 抽象方法，具体的运算由子类实现
    protected abstract void count();

    // 获取生成的运算式
    public String getBinaryOperationStr() {
        return BinaryOperationStr;
    }

    public void setOperands(int one, int two) {
        this.one = one;
        this.two = two;
    }

    public Integer getOne() {
        return one;
    }

    public Integer getTwo() {
        return two;
    }

    public Integer getResult() {
        return result;
    }

    public String getaChar() {
        return aChar;
    }
    public void setResult(int result){
        this.result = result;
    }

    public String getBinaryBaseStr() {
        return BinaryBaseStr;
    }
}
